﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using Tools;
using System.Data;
using System.Data.SqlClient;

namespace DAL
{
   public class ManageUserDAL
    {
        /// <summary>
        /// 用户表
        /// </summary>
        public static List<UserInfo> userdata()
        {
            string sql = "select * from Userinfo";
            SqlDataReader sdr = Tools.DBHelper.ExecuteQuery(sql);
            List<UserInfo> userdata = new List<UserInfo>();
            while (sdr.Read())
            {
                UserInfo user = new UserInfo();

                user.LoginName = (string)sdr["LoginName"];
                user.UserPwd = (string)sdr["UserPwd"];

                userdata.Add(user);
            }
            sdr.Close();
            return userdata;
        }
        public static void register(UserInfo user)
        {
            string sql = string.Format("insert into userinfo([LoginName],[UserPwd]) values('{0}','{1}')", user.LoginName, user.UserPwd);
            DBHelper.Execute(sql);
        }
    }
}
